/**
 * 
 */
package model.admin;

import java.sql.ResultSet;
import java.util.ArrayList;

import myutil.Connect;

import vo.*;

/**
 * @author Sony
 * 
 */
public class GetStudentListMo {

	public ArrayList<StudentDetailsVo> GetStudentDetails() {
		ArrayList<StudentDetailsVo> details = new ArrayList<StudentDetailsVo>();

		StudentDetailsVo detailsVoObject=null;
		Connect c = new Connect();
		ResultSet rs = null;
		String queryToGetStudentDetails = "select * from student_details";
		try {
			rs = c.getResult(queryToGetStudentDetails);

			while (rs.next()) {
				detailsVoObject = new StudentDetailsVo();
				detailsVoObject.setRoll_number(rs.getString("roll_number"));
				detailsVoObject.setStudent_name(rs.getString("student_name"));
				detailsVoObject.setEmail_id(rs.getString("email_id"));
				detailsVoObject.setDate_of_birth(rs.getString("date_of_birth"));
				detailsVoObject.setCity(rs.getString("city"));
				detailsVoObject.setPhone_number(rs.getString("phone_number"));
				details.add(detailsVoObject);
				//System.out.println(rs.getString("roll_number")+rs.getString("student_name")+""+rs.getString("email_id"));
			}

		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return details;

	}

	public ArrayList<StudentDetailsVo> GetStudentAccDetails() {
		ArrayList<StudentDetailsVo> details = new ArrayList<StudentDetailsVo>();

		StudentDetailsVo vo=null;
		Connect c = new Connect();
		ResultSet rs = null,rs1=null;
		String queryToGetStudentDetails = "select * from student_details";
		try {
			rs = c.getResult(queryToGetStudentDetails);

			while (rs.next()) {
				vo = new StudentDetailsVo();
				vo.setRoll_number(rs.getString("roll_number"));
				vo.setStudent_name(rs.getString("student_name"));
				vo.setEmail_id(rs.getString("email_id"));
				vo.setDate_of_birth(rs.getString("date_of_birth"));
				vo.setCity(rs.getString("city"));
				vo.setPhone_number(rs.getString("phone_number"));
				vo.setStudent_id(rs.getInt("student_id"));
				String query2="select * from student_account where student_id="+rs.getInt("student_id");
				rs1=c.getResult(query2);
				while(rs1.next())
				{
					vo.setAcc_id(rs1.getInt("acc_id"));
				}
				details.add(vo);
				//System.out.println(rs.getString("roll_number")+rs.getString("student_name")+""+rs.getString("email_id"));
			}

		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return details;
	}
}
